	set more off
	cap log close
	clear
	cap log close
	set matsize 11000

	*Location of files

	*Your directory

global directory ""
*****************************************************************************
global data_use = "$directory/data_use"
global data_use1 = "$directory//data_use/"
global data_clean = "$directory/data_clean"
global analisis = "$directory/analisis"
global logs = "$directory/logs"
global dos = "$directory/dos"
global prog = "$directory/programs"
*****************************************************************************
 
 	****************************************************************************************************************************
	**********************************************************ANALYSIS WITH ACS SAMPLE******************************************
	****************************************************************************************************************************
	
		
			****This code will create a table for each program: Food stamps (F) and Public Assistance (PA). These tables together reproduce Table 1 in the paper as well as the first stage results in Appendix table 3.

	
	use "$data_clean/acs_stigma_data.dta", clear
	
		
	***1. Running Main Results 
	 
	foreach pname in "F" "PA" {
	
	*******************Main Results******************

		
		*Table 1, Column (1) Main results
		
		probit falseneg_`pname' tract_rate_`pname' /*
		*/if `pname'_i==0 [pw=adjwt], asis cl(tractid)
		outreg2 using "$analisis/acs_stigma_`pname'_probit2_iv1.xml", excel replace ctitle(False Negative. Program: `pname'. Non-imputed Sample. COEF) bdec(4) sdec(4)  se label 
		cap drop sample_`pname'
		gen sample_`pname'=e(sample)
		margins, dydx(tract_rate_`pname') post predict(pr)
		outreg2 using "$analisis/acs_stigma_`pname'_probit2_iv1.xml", excel append ctitle(False Negative. Program: `pname'. Non-imputed Sample. MFX) bdec(4) sdec(4)  se label 

		
		
		*Table 1, Column (2) Controlling for income

		probit falseneg_`pname' tract_rate_`pname' povindex dpov10  /*
		*/if `pname'_i==0 [pw=adjwt], asis cl(tractid)
		outreg2 using "$analisis/acs_stigma_`pname'_probit2_iv1.xml", excel append ctitle(False Negative. Program: `pname'. Non-imputed Sample. COEF) bdec(4) sdec(4)  se label 
		margins, dydx(tract_rate_`pname') post predict(pr)
		outreg2 using "$analisis/acs_stigma_`pname'_probit2_iv1.xml", excel append  ctitle(False Negative. Program: `pname'. Non-imputed Sample. MFX) bdec(4) sdec(4)  se label 

		
		
		*Table 1, Column (3) Controlling for income and more controls

		probit falseneg_`pname' tract_rate_`pname' $takeup mode_2 mode_3 ad_hhmamt_`pname'  ad_hhmth_`pname' rec_time_`pname' i.cty /*
		*/if `pname'_i==0 [pw=adjwt], asis cl(tractid)
		outreg2 using "$analisis/acs_stigma_`pname'_probit2_iv1.xml", excel append ctitle(False Negative. Program: `pname'. Non-imputed Sample. COEF) bdec(4) sdec(4)  se label 
		margins, dydx(tract_rate_`pname') post predict(pr)
		outreg2 using "$analisis/acs_stigma_`pname'_probit2_iv1.xml", excel append  ctitle(False Negative. Program: `pname'. Non-imputed Sample. MFX) bdec(4) sdec(4)  se label 

		
		
		*Appendix Table 3, Column 1 (SNAP) and 2 (TANF+GA): First Stage main 

		reg tract_rate_`pname' iv1 $takeup mode_2 mode_3 ad_hhmamt_`pname'  ad_hhmth_`pname' rec_time_`pname' i.cty   /*
		*/if `pname'_i==0 [pw=adjwt],  cl(tractid)      
		test iv1
		global test=r(F)
		global pval=r(p)
		outreg2 using "$analisis/acs_stigma_`pname'_probit2_iv1.xml", excel append ctitle(iv1: Program: `pname'. First Stage. ) bdec(4) sdec(4)  se label addtext(test, $test, pval, $pval)
		
		
		
		*Table 1, Column (4) Second Stage  
	   
		ivprobit  falseneg_`pname' (tract_rate_`pname' = iv1 ) $takeup mode_2 mode_3 ad_hhmamt_`pname'  ad_hhmth_`pname' rec_time_`pname'  i.cty   /*
		 */if `pname'_i==0 [pw=adjwt], asis cl(tractid)
		outreg2 using "$analisis/acs_stigma_`pname'_probit2_iv1.xml", excel append ctitle(iv1: Program: `pname'. Second Stage COEF) bdec(4) sdec(4)  se label 
		margins, dydx(tract_rate_`pname' ) post predict(pr) 
		outreg2 using "$analisis/acs_stigma_`pname'_probit2_iv1.xml", excel append ctitle(iv1: Program: `pname'. Second Stage MFX) bdec(4) sdec(4)  se label 	
	
		*Appendix Table 3, Column 3 (SNAP) and 4 (TANF+GA): First Stage Mail

		reg tract_rate_`pname' iv1 $takeup mode_2 mode_3 ad_hhmamt_`pname'  ad_hhmth_`pname' rec_time_`pname' i.cty   /*
		*/if `pname'_i==0 & mode_1==1 [pw=adjwt],  cl(tractid)      
		test iv1
		global test=r(F)
		global pval=r(p)
		outreg2 using "$analisis/acs_stigma_`pname'_probit2_iv1.xml", excel append ctitle(iv1: Program: `pname'. First Stage, Mail. ) bdec(4) sdec(4)  se label addtext(test, $test, pval, $pval)
			
			   
		*Table 1, Column (5) Mail Probit: Same regressions as before but condition on "if mode_1==1"
		
			probit falseneg_`pname' tract_rate_`pname' $takeup mode_2 mode_3 ad_hhmamt_`pname'  ad_hhmth_`pname' rec_time_`pname' i.cty /*
		*/if `pname'_i==0 & mode_1==1 [pw=adjwt], asis cl(tractid)
		outreg2 using "$analisis/acs_stigma_`pname'_probit2_iv1.xml", excel append ctitle(False Negative. Program: `pname'. Non-imputed Sample. COEF) bdec(4) sdec(4)  se label 
		margins, dydx(tract_rate_`pname') post predict(pr)
		outreg2 using "$analisis/acs_stigma_`pname'_probit2_iv1.xml", excel append  ctitle(False Negative. Program: `pname'. Non-imputed Sample. MFX) bdec(4) sdec(4)  se label 
	   	
		*Appendix Table 3, Column 5 (SNAP) and 6 (TANF+GA): First Stage Non-Mail 

		reg tract_rate_`pname' iv1 $takeup mode_2 mode_3 ad_hhmamt_`pname'  ad_hhmth_`pname' rec_time_`pname' i.cty   /*
		*/if `pname'_i==0 & mode_1==0 [pw=adjwt],  cl(tractid)      
		test iv1
		global test=r(F)
		global pval=r(p)
		outreg2 using "$analisis/acs_stigma_`pname'_probit2_iv1.xml", excel append ctitle(iv1: Program: `pname'. First Stage, Non-Mail. ) bdec(4) sdec(4)  se label addtext(test, $test, pval, $pval)
		
		*Table 1, Column (6) Non-Mail Probit: Same regressions as before but condition on "if mode_1==0"
		
		probit falseneg_`pname' tract_rate_`pname' $takeup mode_2 mode_3 ad_hhmamt_`pname'  ad_hhmth_`pname' rec_time_`pname' i.cty /*
		*/if `pname'_i==0 & mode_1==0 [pw=adjwt], asis cl(tractid)
		outreg2 using "$analisis/acs_stigma_`pname'_probit2_iv1.xml", excel append ctitle(False Negative. Program: `pname'. Non-imputed Sample. COEF) bdec(4) sdec(4)  se label 
		margins, dydx(tract_rate_`pname') post predict(pr)
		outreg2 using "$analisis/acs_stigma_`pname'_probit2_iv1.xml", excel append  ctitle(False Negative. Program: `pname'. Non-imputed Sample. MFX) bdec(4) sdec(4)  se label 
		
		
		*Table 1, Column (7) Mail IV-Probit: Same regressions as before but condition on "if mode_1==1"
	   
	   ivprobit  falseneg_`pname' (tract_rate_`pname' = iv1 ) $takeup mode_2 mode_3 ad_hhmamt_`pname'  ad_hhmth_`pname' rec_time_`pname'  i.cty   /*
		 */if `pname'_i==0 & mode_1==1  [pw=adjwt], asis cl(tractid)
		outreg2 using "$analisis/acs_stigma_`pname'_probit2_iv1.xml", excel append ctitle(iv1: Program: `pname'. Second Stage COEF) bdec(4) sdec(4)  se label 
		margins, dydx(tract_rate_`pname' ) post predict(pr) 
		outreg2 using "$analisis/acs_stigma_`pname'_probit2_iv1.xml", excel append ctitle(iv1: Program: `pname'. Second Stage MFX) bdec(4) sdec(4)  se label 	
		    

	   	*Table 1, Column (8) Non-Mail IV-Probit: Same regressions as before but condition on "if mode_1==0"

		   ivprobit  falseneg_`pname' (tract_rate_`pname' = iv1 ) $takeup mode_2 mode_3 ad_hhmamt_`pname'  ad_hhmth_`pname' rec_time_`pname'  i.cty   /*
		 */if `pname'_i==0 & mode_1==0  [pw=adjwt], asis cl(tractid)
		outreg2 using "$analisis/acs_stigma_`pname'_probit2_iv1.xml", excel append ctitle(iv1: Program: `pname'. Second Stage COEF) bdec(4) sdec(4)  se label 
		margins, dydx(tract_rate_`pname' ) post predict(pr) 
		outreg2 using "$analisis/acs_stigma_`pname'_probit2_iv1.xml", excel append ctitle(iv1: Program: `pname'. Second Stage MFX) bdec(4) sdec(4)  se label 	
		    
		
		*Table 1, Column (9) Earnings Non-response

		probit impute_earn tract_rate_`pname' $takeup mode_2 mode_3 ad_hhmamt_`pname'  ad_hhmth_`pname' rec_time_`pname' i.cty /*
		*/if `pname'_i==0  [pw=adjwt], asis cl(tractid)
		outreg2 using "$analisis/acs_stigma_`pname'_probit2_iv1.xml", excel append ctitle(Placebo test. Program: `pname'. Non-imputed Sample. COEF) bdec(4) sdec(4)  se label 
		margins, dydx(tract_rate_`pname') post predict(pr)
		outreg2 using "$analisis/acs_stigma_`pname'_probit2_iv1.xml", excel append  ctitle(Placebo test. Program: `pname'. Non-imputed Sample. MFX) bdec(4) sdec(4)  se label 
	

	}
	
	****************************************************************************************************************************
	**********************************************************ANALYSIS WITH CPS SAMPLE******************************************
	****************************************************************************************************************************
	
	
	****This code will create a table for each program: Food stamps (F) and Public Assistance (PA). These tables together reproduce Table 2 in the paper
	
	use "$data_clean/cps_stigma_data.dta", clear

	 
	foreach pname in "F" "PA" {
	
	*******************Main Results******************
	
		
		*Table 2, Column (1) Main results
		
		probit falseneg_`pname' tract_rate_`pname' /*
		*/if `pname'_i==0 [pw=adjwgt], asis
		outreg2 using "$analisis/cps_stigma_`pname'_probit2_iv1.xml", excel replace ctitle(False Negative. Program: `pname'. Non-imputed Sample. COEF) bdec(4) sdec(4)  se label 
		cap drop sample_`pname'
		gen sample_`pname'=e(sample)
		margins, dydx(tract_rate_`pname') post
		outreg2 using "$analisis/cps_stigma_`pname'_probit2_iv1.xml", excel append ctitle(False Negative. Program: `pname'. Non-imputed Sample. MFX) bdec(4) sdec(4)  se label 

		*Table 2, Column (2) Controlling for income

		probit falseneg_`pname' tract_rate_`pname' povindex dpov10  /*
		*/if `pname'_i==0 [pw=adjwgt], asis
		outreg2 using "$analisis/cps_stigma_`pname'_probit2_iv1.xml", excel append ctitle(False Negative. Program: `pname'. Non-imputed Sample. COEF) bdec(4) sdec(4)  se label 
		margins, dydx(tract_rate_`pname') post
		outreg2 using "$analisis/cps_stigma_`pname'_probit2_iv1.xml", excel append  ctitle(False Negative. Program: `pname'. Non-imputed Sample. MFX) bdec(4) sdec(4)  se label 

		*Table 2, Column (3) Controlling for income and more controls

		probit falseneg_`pname' tract_rate_`pname' $takeup ad_hhmamt_`pname'  ad_hhmth_`pname' rec_time_`pname' i.cty /*
		*/if `pname'_i==0 [pw=adjwgt], asis
		outreg2 using "$analisis/cps_stigma_`pname'_probit2_iv1.xml", excel append ctitle(False Negative. Program: `pname'. Non-imputed Sample. COEF) bdec(4) sdec(4)  se label 
		margins, dydx(tract_rate_`pname') post
		outreg2 using "$analisis/cps_stigma_`pname'_probit2_iv1.xml", excel append  ctitle(False Negative. Program: `pname'. Non-imputed Sample. MFX) bdec(4) sdec(4)  se label 

		*Appendix Table 3, Column 7 (SNAP) and 8 (TANF+GA): First Stage main 

		reg tract_rate_`pname' iv1 $takeup ad_hhmamt_`pname'  ad_hhmth_`pname' rec_time_`pname' i.cty   /*
		*/if `pname'_i==0 [pw=adjwgt],  cl(tractid)      
		test iv1
		global test=r(F)
		global pval=r(p)
		outreg2 using "$analisis/cps_stigma_`pname'_probit2_iv1.xml", excel append ctitle(iv1: First Stage. ) bdec(4) sdec(4)  se label addtext(test, $test, pval, $pval)
		
		*Table 2, Column (4) Second Stage  
	   
		ivprobit  falseneg_`pname' (tract_rate_`pname' = iv1 ) $takeup ad_hhmamt_`pname'  ad_hhmth_`pname' rec_time_`pname'  i.cty   /*
		 */if `pname'_i==0 [pw=adjwgt], asis cl(tractid)
		outreg2 using "$analisis/cps_stigma_`pname'_probit2_iv1.xml", excel append ctitle(iv1: Second Stage COEF) bdec(4) sdec(4)  se label 
		
		ivprobit  falseneg_`pname' (tract_rate_`pname' = iv1 ) $takeup ad_hhmamt_`pname'  ad_hhmth_`pname' rec_time_`pname'  i.cty   /*
		 */if `pname'_i==0 [pw=adjwgt], asis cl(tractid)
		margins, dydx(tract_rate_`pname' ) post predict(pr)
		outreg2 using "$analisis/cps_stigma_`pname'_probit2_iv1.xml", excel append ctitle(iv1: Second Stage MFX) bdec(4) sdec(4)  se label 	
		 
		
			
	}
